﻿@model PMS.Models.Base.BaseMenu

@{
    ViewBag.Title = "title";
}

<form action="/Base/BaseMenu/AddOrEdit" method="post" id="mainForm">
    <table>
        <tr>
            <td>字典名称:</td>
            <td><input type="text" class="easyui-textbox" id="Title" name="Title" value="@Model.Title" /></td>
            <td>编号:</td>
            <td><input type="text" class="easyui-textbox" id="Sym" name="Sym" value="@Model.Sym" /></td>
        </tr>
        <tr>
            <td>菜单地址:</td>
            <td colspan="3">
                <input type="text" class="easyui-textbox" id="urlAddress" name="UrlAddress" value="@Model.UrlAddress" style="width: 103%; " />
            </td>
        </tr>
        <tr>
            <td>取值:</td>
            <td><input type="text" class="easyui-textbox" id="value" name="Value" value="@Model.Value" /></td>
            <td>图标:</td>
            <td><input type="text" class="easyui-textbox" id="IocName" name="iocName" value="@Model.IocName" /></td>
        </tr>
        <tr>
            <td>备注信息:</td>
            <td colspan="3">
                <input type="text" class="easyui-textbox" id="remark" name="Remark" value="@Model.Remark" multiline="true" style="width: 102%; height: 60px;" />
            </td>
        </tr>
        <tr>
            <td>是否启用:</td>
            <td>
                <select class="easyui-combobox" name="Enable" id="enable" panelHeight="auto">
                    <option value="1" selected="selected">启用</option>
                    <option value="0">停用</option>
                </select>
            </td>
            <td></td>
            <td></td>
        </tr>
    </table>
    @Html.HiddenFor(x => x.Id)
    @Html.HiddenFor(x => x.CreateBy)
    @Html.HiddenFor(x => x.CreateDate)
    @Html.HiddenFor(x => x.DeleteBy)
    @Html.HiddenFor(x => x.DeleteDate)
    @Html.HiddenFor(x => x.IsLeaf, new { Value = 0 })
    @Html.HiddenFor(x => x.ModifyBy)
    @Html.HiddenFor(x => x.ModifyDate)
    @Html.HiddenFor(x => x.ParentId)
    @Html.HiddenFor(x => x.ParentName)
    @Html.HiddenFor(x => x.Path)
    @Html.HiddenFor(x => x.PathName)
    @Html.HiddenFor(x => x.Sort)
</form>

<script>
    function InitChild() {
        console.log("子页面初始化方法");
        //注 AddType 1表示添加根节点 2表示添加平行节点 3表示添加子节点
        SetModelValue();
    }

    function SetModelValue() {
        var row; //选择的行数据  添加根节点时没有
        var addType = "@ViewBag.AddType";
        debugger;
        switch (addType) {
            case "1":
                $("#ParentId").val(0);
                $("#ParentName").val(" ");
                $("#Path").val(" ");
                $("#PathName").val(" ");
                break;
            case "2":
                row =  getSelectTreeRow();
                $("#ParentId").val(row.ParentId);
                $("#ParentName").val(row.ParentName);
                $("#Path").val(row.Path);
                $("#PathName").val(row.PathName);
                break;
            case "3":
                row = getSelectTreeRow();
                $("#ParentId").val(row.Id);
                $("#ParentName").val(row.Title);
                $("#Path").val(row.ParentId == 0 ? "." + row.Id + "." : row.Path + row.Id + ".");
                $("#PathName").val($.trim(row.Path) == "" ? "." + row.Title + "." : row.Path + row.Title + ".");
                break;
        default:
        }
    }
</script>